package com.suixinsanren.design.adapter.demo02;

public class BirdAdapter implements Duck, Turkey {

    private Duck duck;
    private Turkey turkey;

    public BirdAdapter(Duck duck) {
        this.duck = duck;
    }

    public BirdAdapter(Turkey turkey) {
        this.turkey = turkey;
    }

    @Override
    public void quack() {
        if (duck != null) {
            duck.quack();
        }
        if (turkey != null) {
            turkey.gobble();
        }
    }

    @Override
    public void gobble() {
        quack();
    }

    @Override
    public void fly() {
        if (duck != null) {
            duck.fly();
        }
        if (turkey != null) {
            turkey.fly();
        }
    }
}
